package com.guangfeng.yql.comm.netty.enumerate;

import java.util.Optional;

/**
 * @author yql
 * 直播间信息类型
 */
public enum ChatRoomMessageType {

    cdChatRoot(0,"进入直播间"),
    sendTextMessage(1,"发送信息"),
    quitChatRoot(500,"推出直播间");

    public final Integer code;
    public final String message;
    ChatRoomMessageType(Integer code, String message){
        this.code = code;
        this.message = message;
    }

    public  static ChatRoomMessageType getEnum(Integer code){
        Optional.ofNullable(code).orElseThrow(()-> new NullPointerException("code is null"));
        ChatRoomMessageType[] types = values();
        for (ChatRoomMessageType socketMessageType : types) {
            if (socketMessageType.code.equals(code)){
                return  socketMessageType;
            }
        }
        return null;
    }
}
